﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;

namespace CPPEI.Coolzon.Designer.Views
{
    [ValueConversion(typeof(int), typeof(string))]
    public class TypeToString : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            int int_value = (int)value;
            string ret = string.Empty;
            switch (int_value)
            {
                case Models.Constant.ItemType.Solution: ret = "方案"; break;
                case Models.Constant.ItemType.Scene: ret = "场景"; break;
                case Models.Constant.ItemType.Area: ret = "区域"; break;
                case Models.Constant.ItemType.Resource: ret = "资源"; break;
                case Models.Constant.ItemType.Script: ret = "脚本"; break;
                case Models.Constant.ItemType.Folder: ret = "文件夹"; break;
                case Models.Constant.ItemType.Template: ret = "模板"; break;
                default: ret = "其他"; break;
            }
            return ret;
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            string str_value = (string)value;
            int ret = -1;
            switch (str_value)
            {
                case "方案": ret= Models.Constant.ItemType.Solution; break;
                case "场景": ret = Models.Constant.ItemType.Scene; break;
                case "区域": ret = Models.Constant.ItemType.Area; break;
                case "资源": ret = Models.Constant.ItemType.Resource; break;
                case "脚本": ret = Models.Constant.ItemType.Script; break;
                case "文件夹": ret = Models.Constant.ItemType.Folder; break;
                case "模板": ret = Models.Constant.ItemType.Template; break;
                default: ret = -1; break;
            }
            return ret;
        }
    }
}
